//
//  AppCacheDataManger.m
//  YLCommon
//
//  Created by Apple on 2017/9/26.
//  Copyright © 2017年 Apple. All rights reserved.
//

#import "AppCacheDataManger.h"

@implementation AppCacheDataManger
- (instancetype)init
{
    return [super init];
}
+ (instancetype)new
{
    return [super new];
}
+ (instancetype)shareInstance
{
    static AppCacheDataManger  *_instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [[self alloc]init];
    });
    return _instance;
}

/**
 *  保存数据到沙河中NSUserDefaults
 */
- (void)saveObject:(NSObject *)object forKey:(NSString *)key
{
    if(object == nil) return;
    NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
    [def setObject:object forKey:key];
    [def synchronize];
}

/**
 *  通过key移除数据
 */
- (void)removeForKey:(NSString *)key
{
    NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
    [def removeObjectForKey:key];
    [def synchronize];
}

/**
 *  通过key值获得数据
 */
- (NSObject *)getObectForKey:(NSString *)key
{
    NSUserDefaults *def = [NSUserDefaults standardUserDefaults];
    return [def objectForKey:key];
}



@end
